//
//  WHRegistrationListVCCell.m
//  WHEasyBizLink
//
//  Created by ShengMeng on 9/30/25.
//

#import "WHRegistrationListCell.h"
#import "WHRegistrationListModel.h"
#import "UIView+Rounded.h"
#import "SDAutoLayout.h"
#import "myUILabel.h"

@interface WHRegistrationListCell ()

/// 图标
@property (nonatomic,strong)UIButton *miconBtn;

/// 发起人
@property (nonatomic, weak)UILabel*mIsFQLabel;

/// 名字
@property (nonatomic, weak)UILabel*mNameLabel;

/** 分割线    **/
@property (nonatomic,weak)UIView*separatorLine;

@end

@implementation WHRegistrationListCell

-(void)createUIControls
{
    [super createUIControls];
    self.backgroundColor = [UIColor clearColor];
    
    UIButton * iconBtn = [[UIButton alloc] init];
    iconBtn.titleLabel.font =[UIFont systemFontOfSize:14];
    iconBtn.layer.cornerRadius = 20;
    iconBtn.backgroundColor = whBlueColor;
    [iconBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [iconBtn setTitle:@"姓名" forState:UIControlStateNormal];
    [self.contentView addSubview:iconBtn];
    _miconBtn = iconBtn;
    
    UILabel*isFQLabel = [[UILabel alloc]init];
    isFQLabel.font = [UIFont boldSystemFontOfSize:16];
    isFQLabel.textColor = whBlueColor;
    [self.contentView addSubview:isFQLabel];
    _mIsFQLabel = isFQLabel;
    
    UILabel*nameLabel = [[UILabel alloc]init];
    nameLabel.font = [UIFont boldSystemFontOfSize:16];
    nameLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:nameLabel];
    _mNameLabel = nameLabel;
    
    UIView *Line = [[UIView alloc] init];
    Line.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:Line];
    _separatorLine = Line;
}

-(void)setUpUIControlsLayout
{
    [super setUpUIControlsLayout];
    
    _miconBtn
    .sd_layout
    .topSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .leftSpaceToView(self.contentView, 15)
    .widthIs(40);
    
    _mNameLabel
    .sd_layout
    .topSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .leftSpaceToView(self.miconBtn, 5)
    .rightSpaceToView(self.contentView, 90);
    
    _mIsFQLabel
    .sd_layout
    .topSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .widthIs(80);
    
    _separatorLine
    .sd_layout
    .bottomSpaceToView(self.contentView, 1)
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .heightIs(1);
    
}

-(void)setModel:(WHRegistrationListModel *)model
{
    _model = model;
    if(model.username.length>1)
    {
        NSString *name = [model.username substringWithRange:NSMakeRange(model.username.length-2,2)];

        [self.miconBtn setTitle:name forState:UIControlStateNormal];
    }
    
    self.mNameLabel.text = [NSString stringWithFormat:@"%@",(long)model.username];
    self.mIsFQLabel.text  = [NSString stringWithFormat:@"钓位号: %ld", (long)model.fishingSpotNumber];
}

@end
